typedef enum
{
    MQTT_STATE_CONNECTED,
    MQTT_STATE_DISCONNECTED,
    MQTT_STATE_INIT,
    MQTT_STATE_CONNECTING,
    MQTT_STATE_CONNECT_FAILED,
    MQTT_STATE_SUBSCRIBE_FAILED,
    MQTT_STATE_SUBSCRIBE_SUCCESS,
    MQTT_STATE_PUBLISH_FAILED,
    MQTT_STATE_DATA,
} lyn_mqtt_state_t;

typedef struct
{
    lyn_mqtt_state_t state;
    char *topic;
    char *payload;
    int qos;
    int retain;
} lyn_mqtt_message_t;



typedef void (*lyn_mqtt_listener_t)(lyn_mqtt_state_t state, void *arg);

void lyn_mqtt_start(char * uri, int port, char * clientId, char * userName, char * password, lyn_mqtt_listener_t listener);

void lyn_mqtt_stop(void);

void disconnect_lyn_mqtt(void);

void reconnect_lyn_mqtt(void);

int subscribe_lyn_topic(const char* topic,int qos);

int unsubscribe_lyn_topic(const  char* topic);

int publish_lyn_topic(const char* topic,const char* payload,int qos,int retain);